//题目链接：https://leetcode.cn/problems/kth-node-from-end-of-list-lcci/
class Solution 
{
public:
    int kthToLast(ListNode* head, int k) 
    {
        
        ListNode* slow=head;
        ListNode* fast=slow;
        while(k--)
        {
            fast=fast->next;
        }
        while(fast)
        {
            fast=fast->next;
            slow=slow->next;
        }
        return slow->val;

    }
};